#include <iostream>
#define N 100

using namespace std;

void readintVector(float array[], int elements){
for (int i=0; i<elements; i++){
	cout<<"a["<<i<<"]=";
	cin>>array[i];
	cout<<"\n";}
}

int insert_average(float array[], int elements)
{
	int i, j, avg=elements;
	for(i=1;i<elements;i++){
		for (j=elements;j>i;--j)
			array[j]=array[j-1];				
		array[i]=(array[i-1]+array[i+1])/2;
		++elements;
		++i;	
			}
return elements;			
}


void printintVector(float array[], int avg){
for (int i=0; i<avg; i++){
	cout<<array[i]<<" ";}
	cout<<"\n";
}


int main(){
float array[N];
int elements,avg;
cout<<"Type the number of elements you want in the array: ";
cin>>elements;
readintVector(array, elements);

cout<<"The original array is ";
for(int i=0; i<elements; i++){
	cout<<array[i]<<" ";}
cout<<endl;
avg=insert_average(array, elements);
cout<<"The array with the average inserted between elements is ";
printintVector(array, avg);
return 0;
}

